<?php

/**
*	监控  ws 8811
*
*/

define("APP_PATH",__DIR__."/../../application/");
// 加载框架里面的文件
//require __DIR__."/../thinkphp/base.php";
require __DIR__."/../../thinkphp/start.php";

class  server{
	
	CONST PORT =8812;
	
	// 监控8811 
	public function checkport(){
		$shell = "netstat -anp 2>/dev/null | grep ". self::PORT . " | grep LISTEN | wc -l";
		
		$res = shell_exec($shell);	
		
		if($res == 1){
			echo date("Y-m-d H:i:s")."this is server success ".PHP_EOL;
		}else{
			
			$obj = new app\common\lib\Task;
			$obj->sendSms(array('mobile'=>'15349295461','code'=>888888));
			
		}
	}
	
}


swoole_timer_tick(10000,function(){
	
	(new server)->checkport();
	
	echo "time start ".PHP_EOL;
	
});


?>